package com.ybb.account.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ybb.account.entity.UserAccountEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserAccountMapper extends BaseMapper<UserAccountEntity> {

    @Select("select balance from ybb_user_account where code=#{code} lock in share mode")
    Double getUserAccountBalanceInLock(@Param("code") String code);

    @Update("update ybb_user_account set balance=balance+#{amount}  where code=#{code}")
    Integer changeAccount(@Param("code") String code, @Param("amount") Double amount);


}
